package com.hangxiang.approval.controller;

import com.hangxiang.approval.common.ApproveInsertCommon;
import com.hangxiang.approval.common.ApproveUpdateCommon;
import com.hangxiang.approval.common.IntegerCommon;
import com.hangxiang.approval.common.ResultBean;
import com.hangxiang.approval.service.ApproveService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 审批表(Approve)表控制层
 *
 * @author makejava
 * @since 2020-11-23 18:06:12
 */
@RestController
@RequestMapping("approve")
@Api(tags = "审批表Approve相关功能")
public class ApproveController {
    /**
     * 服务对象
     */
    @Resource
    private ApproveService approveService;

    /**
     * 通过主键查询单条数据
     *
     * @param common 主键
     * @return 单条数据
     */
    @PostMapping("selectOne")
    @ApiOperation(value = "通过主键查询单条数据")
    @ResponseBody
    public ResultBean selectOne(@RequestBody @Validated IntegerCommon common) {
        return ResultBean.success(approveService.queryById(common));
    }

    /**
     * 新增数据
     *
     * @param approveInsertCommon 实例对象
     * @return 实例对象
     */
    @PostMapping("insertApprove")
    @ApiOperation(value = "添加数据")
    @ResponseBody
    public ResultBean insert(@RequestBody @Validated ApproveInsertCommon approveInsertCommon) {
        return ResultBean.success(approveService.insertApprove(approveInsertCommon));
    }

    /**
     * 新增数据
     *
     * @param approveUpdateCommon 实例对象
     * @return 实例对象
     */
    @PostMapping("updateApprove")
    @ApiOperation(value = "修改数据")
    @ResponseBody
    public ResultBean update(@RequestBody @Validated ApproveUpdateCommon approveUpdateCommon) {
        return ResultBean.success(approveService.updateApprove(approveUpdateCommon));
    }


}